// pages/mall/goods_detail/goods_detail.js
Page({

    data: {
        goods:'',
        xilie:'',
        height:'0rpx',
        color:false,
        select:0,
        select_lolor:'',
        tanchu:'',
        aixin:false
    },
    onLoad(options) {
        console.log(options.id);
        var that=this
        wx.cloud.database().collection('goods').where({
            _id:options.id
        }).get({
            success(res){
                that.setData({
                    goods:res.data[0],
                })
                
            }
        })
    },
    
    onShow(){
        var xilie=''
        if (this.data.goods.type=='richang'){
            xilie='日常用品'
        }else if(this.data.goods.type=='wenju'){
            xilie='文具'
        }else if(this.data.goods.type=='shougong'){
            xilie='手工制品'
        }else{
            xilie='纪念品'
        }
        this.setData({
            xilie:xilie, 
        })
        
    },
    handleColor(){
    
        let a=this.data.color==false?true:false
        this.setData({
          color:a,
        })
      },
      handleSpring(){
        const a=this.data.height=='0rpx'?'1000rpx':'0rpx'
        const b=this.data.tanchu==true?false:true
        this.setData({
          height:a,
          tanchu:b,
          select:this.data.goods.detail_image[0]
        })
      },
      select(e){
          console.log(e.target.dataset.index);
          this.setData({
              select:this.data.goods.detail_image[e.target.dataset.index] ,
              select_lolor:e.target.dataset.index
          })
      }


})